<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <h:form id="kullanici" styleClass="edit">

        <rich:panel>
            <f:facet name="header">#{kullaniciHome.managed ? 'Edit' : 'Add'} Kullanici</f:facet>

            <s:decorate id="adField" template="layout/edit.xhtml">
                <ui:define name="label">Ad</ui:define>
                <h:inputText id="ad" cols="80" rows="10" required="true" value="#{kullaniciHome.instance.ad}"/>
            </s:decorate>

            <s:decorate id="kodField" template="layout/edit.xhtml">
                <ui:define name="label">Kod</ui:define>
                <h:inputText id="kod" cols="80" rows="3" required="true" value="#{kullaniciHome.instance.kod}"/>
            </s:decorate>

            <s:decorate id="parolaField" template="layout/edit.xhtml">
                <ui:define name="label">Parola</ui:define>
                <h:inputText id="parola" cols="80" rows="3" required="true" value="#{kullaniciHome.instance.parola}"/>
            </s:decorate>

			<s:decorate id="authorizedPeopleField" template="/layout/edit.xhtml">
				<ui:define name="label">Rol Atama</ui:define>
				<rich:pickList value="#{kullaniciHome.instance.rols}" id="peoplePickList"
						copyControlLabel="Ekle"
						copyAllControlLabel="Hepsini Ekle"
						removeControlLabel="Çıkar"
						removeAllControlLabel="Hepsini Çıkar"
						sourceCaptionLabel="Atanmamış Roller"
			            targetCaptionLabel="Atanmış Roller"
						listsHeight="172"
					    sourceListWidth="180" 
					    targetListWidth="180">
					<s:selectItems var="rol" value="#{rolList.resultList}" label="#{rol.ad}" />
					<s:convertEntity />
					<a:support event="onlistchanged"  ajaxSingle="true" />
				</rich:pickList>
			</s:decorate>

            <div style="clear:both">
                <span class="required">*</span>
                required fields
            </div>

        </rich:panel>

        <div class="actionButtons">

            <h:commandButton id="save"
                          value="Save"
                         action="#{kullaniciHome.persist}"
                       disabled="#{!kullaniciHome.wired}"
                       rendered="#{!kullaniciHome.managed}"/>

            <h:commandButton id="update"
                          value="Save"
                         action="#{kullaniciHome.update}"
                       rendered="#{kullaniciHome.managed}"/>

            <h:commandButton id="delete"
                          value="Delete"
                         action="#{kullaniciHome.remove}"
                      immediate="true"
                       rendered="#{kullaniciHome.managed}"/>

            <s:button id="cancelEdit"
                   value="Cancel"
             propagation="end"
                    view="/Kullanici.xhtml"
                rendered="#{kullaniciHome.managed}"/>

            <s:button id="cancelAdd"
                   value="Cancel"
             propagation="end"
                    view="/#{empty kullaniciFrom ? 'KullaniciList' : kullaniciFrom}.xhtml"
                rendered="#{!kullaniciHome.managed}"/>

        </div>
    </h:form>

<rich:tabPanel switchType="ajax">

    <rich:tab label="Firma *" labelClass="required" rendered="#{kullaniciHome.instance.firma == null || authenticator.isAdmin()}">
    <div class="association" id="firmaParent">

        <h:outputText value="There is no firma associated with this kullanici."
                   rendered="#{kullaniciHome.instance.firma == null}"/>

        <rich:dataTable var="_firma"
                   value="#{kullaniciHome.instance.firma}"
                rendered="#{kullaniciHome.instance.firma != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="firmaTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_firma.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Kod</f:facet>
                <h:outputText value="#{_firma.kod}"/>
            </h:column>            
            <h:column>
                <f:facet name="header">Ad</f:facet>
                <h:outputText value="#{_firma.ad}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Adres</f:facet>
                <h:outputText value="#{_firma.adres}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Eposta</f:facet>
                <h:outputText value="#{_firma.eposta}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Telefon</f:facet>
                <h:outputText value="#{_firma.telefon}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Vergino</f:facet>
                <h:outputText value="#{_firma.vergino}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Webadresi</f:facet>
                <h:outputText value="#{_firma.webadresi}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Mersisno</f:facet>
                <h:outputText value="#{_firma.mersisno}"/>
            </h:column>            
        </rich:dataTable>

        <div class="actionButtons">
            <s:button id="#{kullaniciHome.instance.firma != null ? 'changeParent' : 'selectParent'}" value="#{kullaniciHome.instance.firma != null ? 'Change' : 'Select'} firma"
                       view="/FirmaList.xhtml">
                <f:param name="from" value="KullaniciEdit"/>
            </s:button>
        </div>

    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
